/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sdd.facades.business;

import com.sdd.entities.Feature;
import com.sdd.entities.FeatureCategory;
import com.sdd.facades.factories.FeatureCategoryFactoryFacadeBean;
import com.sdd.facades.persistence.FeaturePersistenceFacade;
import com.sdd.plains.FeaturePlain;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;

/**
 *
 * @author T
 */
@Stateless
@LocalBean
public class FeatureBusinessFacadeBean {
    @EJB
    FeaturePersistenceFacade featurePersistenceFacade;
    @EJB
    FeatureCategoryFactoryFacadeBean fcffb;
    @EJB
    FeatureCategoryBusinessFacadeBean fcbfb;
    
        
    public Feature getFeature(Long id){
        return featurePersistenceFacade.find(id);
    }    
    
    public List<Feature> getFeatureFromFeatureCategory(Long idfc){
        FeatureCategory featureCategory = fcbfb.getFeatureCategory(idfc);
        return featurePersistenceFacade.getFeaturesInFeatureCategory(featureCategory);
    }
    
    public Feature addFeature(FeaturePlain plain){
        Feature f = new Feature();
        f.setId(plain.getId());
        f.setSummary(plain.getSummary());
        f.setDescription(plain.getDescription());
        f.setCategory(fcffb.createFeatureCategory(plain.getCategory()));        
        return featurePersistenceFacade.create(f);
    }
     public Feature addFeature(Feature f){
        return featurePersistenceFacade.create(f);
    }
    
}
